<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>tinydtls: ccm.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">tinydtls
   &#160;<span id="projectnumber">0.8.2</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Groups</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">ccm.c File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &lt;string.h&gt;</code><br/>
<code>#include &quot;<a class="el" href="dtls__config_8h_source.html">dtls_config.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="global_8h_source.html">global.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="numeric_8h_source.html">numeric.h</a>&quot;</code><br/>
<code>#include &quot;<a class="el" href="ccm_8h_source.html">ccm.h</a>&quot;</code><br/>
<code>#include &lt;assert.h&gt;</code><br/>
</div>
<p><a href="ccm_8c_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a18f6fffa08314e79c95e2de10e7409cb"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ccm_8c.html#a18f6fffa08314e79c95e2de10e7409cb">CCM_FLAGS</a>(A, M, L)&#160;&#160;&#160;(((A &gt; 0) &lt;&lt; 6) | (((M - 2)/2) &lt;&lt; 3) | (L - 1))</td></tr>
<tr class="separator:a18f6fffa08314e79c95e2de10e7409cb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a46e95fc2cb115ab9c342707ec443265f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ccm_8c.html#a46e95fc2cb115ab9c342707ec443265f">MASK_L</a>(_L)&#160;&#160;&#160;((1 &lt;&lt; 8 * _L) - 1)</td></tr>
<tr class="separator:a46e95fc2cb115ab9c342707ec443265f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a13d9e1fa611f50a7176fd6da7b1b4994"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ccm_8c.html#a13d9e1fa611f50a7176fd6da7b1b4994">SET_COUNTER</a>(A, L, cnt, C)</td></tr>
<tr class="separator:a13d9e1fa611f50a7176fd6da7b1b4994"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a1dfe92428f63772e3907a26435e54354"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ccm_8c.html#a1dfe92428f63772e3907a26435e54354">block0</a> (size_t M, size_t L, size_t la, size_t lm, unsigned char nonce[<a class="el" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a>], unsigned char *result)</td></tr>
<tr class="separator:a1dfe92428f63772e3907a26435e54354"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a59faf5a2a638dc03c01605d4bebe0bcc"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ccm_8c.html#a59faf5a2a638dc03c01605d4bebe0bcc">add_auth_data</a> (rijndael_ctx *ctx, const unsigned char *msg, size_t la, unsigned char B[<a class="el" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a>], unsigned char X[<a class="el" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a>])</td></tr>
<tr class="separator:a59faf5a2a638dc03c01605d4bebe0bcc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a983462ca57ee8fe54249c77281f6559e"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ccm_8c.html#a983462ca57ee8fe54249c77281f6559e">encrypt</a> (rijndael_ctx *ctx, size_t L, unsigned long counter, unsigned char *msg, size_t len, unsigned char A[<a class="el" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a>], unsigned char S[<a class="el" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a>])</td></tr>
<tr class="separator:a983462ca57ee8fe54249c77281f6559e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af90d9a6bdae478b53926bf6f1bd6c9d5"><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ccm_8c.html#af90d9a6bdae478b53926bf6f1bd6c9d5">mac</a> (rijndael_ctx *ctx, unsigned char *msg, size_t len, unsigned char B[<a class="el" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a>], unsigned char X[<a class="el" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a>])</td></tr>
<tr class="separator:af90d9a6bdae478b53926bf6f1bd6c9d5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a40f4f23b5687e18dc1bce1c19101da42"><td class="memItemLeft" align="right" valign="top">long int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ccm_8c.html#a40f4f23b5687e18dc1bce1c19101da42">dtls_ccm_encrypt_message</a> (rijndael_ctx *ctx, size_t M, size_t L, unsigned char nonce[<a class="el" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a>], unsigned char *msg, size_t lm, const unsigned char *aad, size_t la)</td></tr>
<tr class="separator:a40f4f23b5687e18dc1bce1c19101da42"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa3e92bdeca1d0730d48b8a85181d5b6d"><td class="memItemLeft" align="right" valign="top">long int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="ccm_8c.html#aa3e92bdeca1d0730d48b8a85181d5b6d">dtls_ccm_decrypt_message</a> (rijndael_ctx *ctx, size_t M, size_t L, unsigned char nonce[<a class="el" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a>], unsigned char *msg, size_t lm, const unsigned char *aad, size_t la)</td></tr>
<tr class="separator:aa3e92bdeca1d0730d48b8a85181d5b6d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="a18f6fffa08314e79c95e2de10e7409cb"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define CCM_FLAGS</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">A, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">M, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">L&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td>&#160;&#160;&#160;(((A &gt; 0) &lt;&lt; 6) | (((M - 2)/2) &lt;&lt; 3) | (L - 1))</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="ccm_8c_source.html#l00037">37</a> of file <a class="el" href="ccm_8c_source.html">ccm.c</a>.</p>

</div>
</div>
<a class="anchor" id="a46e95fc2cb115ab9c342707ec443265f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MASK_L</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">_L</td><td>)</td>
          <td>&#160;&#160;&#160;((1 &lt;&lt; 8 * _L) - 1)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="ccm_8c_source.html#l00039">39</a> of file <a class="el" href="ccm_8c_source.html">ccm.c</a>.</p>

</div>
</div>
<a class="anchor" id="a13d9e1fa611f50a7176fd6da7b1b4994"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define SET_COUNTER</td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">A, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">L, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">cnt, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">&#160;</td>
          <td class="paramname">C&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<b>Value:</b><div class="fragment"><div class="line">{                   \</div>
<div class="line">    int i;                              \</div>
<div class="line">    memset((A) + <a class="code" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a> - (L), 0, (L));         \</div>
<div class="line">    (C) = (cnt) &amp; <a class="code" href="ccm_8c.html#a46e95fc2cb115ab9c342707ec443265f">MASK_L</a>(L);                        \</div>
<div class="line">    for (i = <a class="code" href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a> - 1; (C) &amp;&amp; (i &gt; (L)); --i, (C) &gt;&gt;= 8)  \</div>
<div class="line">      (A)[i] |= (C) &amp; 0xFF;                     \</div>
<div class="line">  }</div>
<div class="ttc" id="ccm_8c_html_a46e95fc2cb115ab9c342707ec443265f"><div class="ttname"><a href="ccm_8c.html#a46e95fc2cb115ab9c342707ec443265f">MASK_L</a></div><div class="ttdeci">#define MASK_L(_L)</div><div class="ttdef"><b>Definition:</b> <a href="ccm_8c_source.html#l00039">ccm.c:39</a></div></div>
<div class="ttc" id="ccm_8h_html_a5c46c97c6c3ef5d4e5bd616dbd064859"><div class="ttname"><a href="ccm_8h.html#a5c46c97c6c3ef5d4e5bd616dbd064859">DTLS_CCM_BLOCKSIZE</a></div><div class="ttdeci">#define DTLS_CCM_BLOCKSIZE</div><div class="ttdef"><b>Definition:</b> <a href="ccm_8h_source.html#l00033">ccm.h:33</a></div></div>
</div><!-- fragment -->
<p>Definition at line <a class="el" href="ccm_8c_source.html#l00041">41</a> of file <a class="el" href="ccm_8c_source.html">ccm.c</a>.</p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="a59faf5a2a638dc03c01605d4bebe0bcc"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void add_auth_data </td>
          <td>(</td>
          <td class="paramtype">rijndael_ctx *&#160;</td>
          <td class="paramname"><em>ctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const unsigned char *&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>la</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>B</em>[DTLS_CCM_BLOCKSIZE], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>X</em>[DTLS_CCM_BLOCKSIZE]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<p>Creates the CBC-MAC for the additional authentication data that is sent in cleartext.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ctx</td><td>The crypto context for the AES encryption. </td></tr>
    <tr><td class="paramname">msg</td><td>The message starting with the additional authentication data. </td></tr>
    <tr><td class="paramname">la</td><td>The number of additional authentication bytes in <code>msg</code>. </td></tr>
    <tr><td class="paramname">B</td><td>The input buffer for crypto operations. When this function is called, <code>B</code> must be initialized with <code>B0</code> (the first authentication block. </td></tr>
    <tr><td class="paramname">X</td><td>The output buffer where the result of the CBC calculation is placed. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The result is written to <code>X</code>. </dd></dl>

<p>Definition at line <a class="el" href="ccm_8c_source.html#l00084">84</a> of file <a class="el" href="ccm_8c_source.html">ccm.c</a>.</p>

</div>
</div>
<a class="anchor" id="a1dfe92428f63772e3907a26435e54354"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void block0 </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>M</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>L</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>la</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>lm</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>nonce</em>[DTLS_CCM_BLOCKSIZE], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&#160;</td>
          <td class="paramname"><em>result</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="ccm_8c_source.html#l00050">50</a> of file <a class="el" href="ccm_8c_source.html">ccm.c</a>.</p>

</div>
</div>
<a class="anchor" id="aa3e92bdeca1d0730d48b8a85181d5b6d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">long int dtls_ccm_decrypt_message </td>
          <td>(</td>
          <td class="paramtype">rijndael_ctx *&#160;</td>
          <td class="paramname"><em>ctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>M</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>L</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>nonce</em>[DTLS_CCM_BLOCKSIZE], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>lm</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const unsigned char *&#160;</td>
          <td class="paramname"><em>aad</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>la</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="ccm_8c_source.html#l00240">240</a> of file <a class="el" href="ccm_8c_source.html">ccm.c</a>.</p>

</div>
</div>
<a class="anchor" id="a40f4f23b5687e18dc1bce1c19101da42"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">long int dtls_ccm_encrypt_message </td>
          <td>(</td>
          <td class="paramtype">rijndael_ctx *&#160;</td>
          <td class="paramname"><em>ctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>M</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>L</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>nonce</em>[DTLS_CCM_BLOCKSIZE], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>lm</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const unsigned char *&#160;</td>
          <td class="paramname"><em>aad</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>la</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Authenticates and encrypts a message using AES in CCM mode. Please see also RFC 3610 for the meaning of <code>M</code>, <code>L</code>, <code>lm</code> and <code>la</code>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ctx</td><td>The initialized rijndael_ctx object to be used for AES operations. </td></tr>
    <tr><td class="paramname">M</td><td>The number of authentication octets. </td></tr>
    <tr><td class="paramname">L</td><td>The number of bytes used to encode the message length. </td></tr>
    <tr><td class="paramname">N</td><td>The nonce value to use. You must provide <code>DTLS_CCM_BLOCKSIZE</code> nonce octets, although only the first <code>16</code> - <code>L</code> are used. </td></tr>
    <tr><td class="paramname">msg</td><td>The message to encrypt. The first <code>la</code> octets are additional authentication data that will be cleartext. Note that the encryption operation modifies the contents of <code>msg</code> and adds <code>M</code> bytes MAC. Therefore, the buffer must be at least <code>lm</code> + <code>M</code> bytes large. </td></tr>
    <tr><td class="paramname">lm</td><td>The actual length of <code>msg</code>. </td></tr>
    <tr><td class="paramname">aad</td><td>A pointer to the additional authentication data (can be <code>NULL</code> if <code>la</code> is zero). </td></tr>
    <tr><td class="paramname">la</td><td>The number of additional authentication octets (may be zero). </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>FIXME </dd></dl>

<p>Definition at line <a class="el" href="ccm_8c_source.html#l00176">176</a> of file <a class="el" href="ccm_8c_source.html">ccm.c</a>.</p>

</div>
</div>
<a class="anchor" id="a983462ca57ee8fe54249c77281f6559e"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void encrypt </td>
          <td>(</td>
          <td class="paramtype">rijndael_ctx *&#160;</td>
          <td class="paramname"><em>ctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>L</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned long&#160;</td>
          <td class="paramname"><em>counter</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>A</em>[DTLS_CCM_BLOCKSIZE], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>S</em>[DTLS_CCM_BLOCKSIZE]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="ccm_8c_source.html#l00149">149</a> of file <a class="el" href="ccm_8c_source.html">ccm.c</a>.</p>

</div>
</div>
<a class="anchor" id="af90d9a6bdae478b53926bf6f1bd6c9d5"></a>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">static void mac </td>
          <td>(</td>
          <td class="paramtype">rijndael_ctx *&#160;</td>
          <td class="paramname"><em>ctx</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&#160;</td>
          <td class="paramname"><em>msg</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>len</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>B</em>[DTLS_CCM_BLOCKSIZE], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char&#160;</td>
          <td class="paramname"><em>X</em>[DTLS_CCM_BLOCKSIZE]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">static</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Definition at line <a class="el" href="ccm_8c_source.html#l00162">162</a> of file <a class="el" href="ccm_8c_source.html">ccm.c</a>.</p>

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Feb 27 2015 15:15:33 for tinydtls by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>
